package com.design.movieticket.controller;

import com.design.movieticket.common.base.constant.Result;
import com.design.movieticket.common.base.constant.ResultStatus;
import com.design.movieticket.entity.Comment;
import com.design.movieticket.service.CommentService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "评论模块")
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Resource
    private CommentService commentService;

    @PostMapping("/submitContent")
    public Result submitContent(@RequestBody Comment comment){
        commentService.submitContent(comment);
        return new Result(ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }

    @GetMapping("/getComment")
    public Result getComment(Long movieId){
        return new Result(commentService.getComment(movieId),ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }

    @GetMapping("/getStartScore")
    public Result getStartScore(Long movieId){
        return new Result(commentService.getStartScore(movieId),ResultStatus.REQUEST_SUCCESS.getMsg(),ResultStatus.REQUEST_SUCCESS.getCode());
    }

    @PostMapping("/delComment")
    public Result delComment(Long commentId){
        commentService.delComment(commentId);
        return new Result(ResultStatus.DELETE_SUCCESS.getMsg(),ResultStatus.DELETE_SUCCESS.getCode());
    }
}
